home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / portable / delwin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  1.7 KB  |  74 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #undef    delwin
  4.  
  5. #ifdef PDCDEBUG
  6. char *rcsid_delwin = "$Header: C:\CURSES\portable\RCS\delwin.c 2.1 1993/06/18 20:19:08 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   delwin()    - delete window
  15.  
  16.   X/Open Description:
  17.      Deletes the named window, freeing all memory associated with it.
  18.      In the case of overlapping windows, subwindows should be deleted
  19.      before the main window.
  20.  
  21.   PDCurses Description:
  22.      This routine will also attempt to remove the passed window from
  23.      the visible window's list.  This is a list of windows that are
  24.      "visible" and will always be refreshed at the next doupdate()
  25.      call.
  26.  
  27.   X/Open Return Value:
  28.      The delwin() function returns OK on success and ERR on error.
  29.  
  30.   PDCurses Errors:
  31.      It is an error to call this function with a NULL window pointer.
  32.  
  33.   Portability:
  34.      PDCurses    int delwin( WINDOW* win );
  35.      X/Open Dec '88    int delwin( WINDOW* win );
  36.      BSD Curses    int delwin( WINDOW* win );
  37.      SYS V Curses    int delwin( WINDOW* win );
  38. **man-end**********************************************************************/
  39.  
  40. int    delwin(WINDOW *win)
  41. {
  42. extern    void    (*fre)( void* );
  43.     int    i;
  44.  
  45. #ifdef PDCDEBUG
  46.     if (trace_on) PDC_debug("delwin() - called\n");
  47. #endif
  48.  
  49.  
  50.     if (win == (WINDOW *)NULL)
  51.         return( ERR );
  52.  
  53. #ifdef    REGISTERWINDOWS
  54.     _rmwin(win);        /* Remove from the visible windows list... */
  55. #endif
  56.  
  57.     /*
  58.      * FYI:  Subwindow's use 'parent's' lines
  59.      */
  60.     if (!(win->_flags & _SUBWIN))
  61.     {
  62.         for (i = 0; i < win->_pmaxy && win->_y[i]; i++)
  63.         {
  64.             if (win->_y[i] != NULL)
  65.                 (*fre)(win->_y[i]);
  66.         }
  67.     }
  68.     (*fre)(win->_firstch);
  69.     (*fre)(win->_lastch);
  70.     (*fre)(win->_y);
  71.     (*fre)(win);
  72.     return( OK );
  73. }
  74.